
package com.airplane.hotdiscuss.ui;

import com.airplane.hotdiscuss.R;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.KeyEvent;

public class AboutActivity extends Activity {

    private static final int DIALOG_ABOUT = 1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        showDialog(DIALOG_ABOUT);
    }

    @Override
    protected Dialog onCreateDialog(int id) {
        super.onCreateDialog(id);

        AlertDialog dialog = null;
        switch (id) {
            case DIALOG_ABOUT:
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setTitle(R.string.app_name);
                builder.setIcon(android.R.drawable.ic_dialog_info);
                builder.setMessage(R.string.app_name);
                builder.setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                    }
                });
                builder.setOnKeyListener(new DialogInterface.OnKeyListener() {
                    public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                        if (event.getAction() == KeyEvent.ACTION_DOWN) {
                            if (keyCode == KeyEvent.KEYCODE_BACK || keyCode ==KeyEvent.KEYCODE_DPAD_CENTER) {
                                finish();
                            }
                        }
                        return true;
                    }
                });
                dialog = builder.create();
        }

        return dialog;
    }
}
